#ifndef LCD_H
#define LCH_H
#include <stdint.h>

#define RED  	0xf800
#define GREEN	0x07e0
#define BLUE 	0x001f
#define WHITE	0xffff
#define BLACK	0x0000
#define YELLOW  0xFFE0
#define GRAY0   0xEF7D   	//��ɫ0 3165 00110 001011 00101
#define GRAY1   0x8410      	//��ɫ1      00000 000000 00000
#define GRAY2   0x4208      	//��ɫ2  1111111111011111

#define X_MAX_PIXEL	        128
#define Y_MAX_PIXEL	        160


#define LCD_CTRLA   	  	GPIOA		//����TFT���ݶ˿�
#define LCD_CTRLB   	  	GPIOB		//����TFT���ݶ˿�



#define LCD_SCL        	PA7
#define LCD_SDA        	PA6
#define LCD_CS        	PA4
#define LCD_LED        	PNO
#define LCD_DC         	PA5
#define LCD_RST     	PC4
//#define LCD_CS_SET(x) LCD_CTRL->ODR=(LCD_CTRL->ODR&~LCD_CS)|(x ? LCD_CS:0)


#define	LCD_SCL_SET  	IOWrite(LCD_SCL, 1);
#define	LCD_SDA_SET  	IOWrite(LCD_SDA, 1);
#define	LCD_CS_SET  	IOWrite(LCD_CS,  1);

#define	LCD_LED_SET  	IOWrite(LCD_LED, 1);
#define	LCD_DC_SET  	IOWrite(LCD_DC,  1);
#define	LCD_RST_SET  	IOWrite(LCD_RST, 1);

#define	LCD_SCL_CLR  	IOWrite(LCD_SCL, 0);  
#define	LCD_SDA_CLR  	IOWrite(LCD_SDA, 0); 
#define	LCD_CS_CLR  	IOWrite(LCD_CS,  0);
    
#define	LCD_LED_CLR  	IOWrite(LCD_LED, 0); 
#define	LCD_DC_CLR  	IOWrite(LCD_DC,  0);
#define	LCD_RST_CLR  	IOWrite(LCD_RST, 0);


void LCD_GPIO_Init(void);
void Lcd_WriteIndex(uint8_t Index);
void Lcd_WriteData(uint8_t Data);
void Lcd_WriteReg(uint8_t Index,uint8_t Data);
uint16_t Lcd_ReadReg(uint8_t LCD_Reg);
void Lcd_Reset(void);
void Lcd_Init(void);
void Lcd_Clear(uint16_t Color);
void Lcd_SetXY(uint16_t x,uint16_t y);
void Gui_DrawPoint(uint16_t x,uint16_t y,uint16_t Data);
void Lcd_SetRegion(uint16_t x_start,uint16_t y_start,uint16_t x_end,uint16_t y_end);
void LCD_WriteData_16Bit(uint16_t Data);

#endif
